package com.bond.jumper.client.util;

import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtils {

    private static Properties properties;

    public static final String KEY_SERVER_IP ="netty.server.ip";
    public static final String KEY_SERVER_PORT ="netty.server.port";
    public static final String KEY_CLIENT_RECONNET_INTERVAL ="netty.client.reconnectInterval";

    static {
        // 读取配置文件
        properties = new Properties();
        try (InputStream input = PropertiesUtils.class.getClassLoader().getResourceAsStream("application.properties")) {
            properties.load(input);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String getPropString(String key) {
        return properties.getProperty(key);
    }

    public static int getPropInt(String key) {
        return Integer.parseInt(properties.getProperty(key));
    }

    public static String getServerIp(){
        return getPropString(KEY_SERVER_IP);
    }

    public static int getServerPort(){
        return getPropInt(KEY_SERVER_PORT);
    }

    public static int getClientReconnetInterval(){
        return getPropInt(KEY_CLIENT_RECONNET_INTERVAL);
    }

}
